//package com.mayikt.jwt;
//
//import com.alibaba.fastjson.JSONObject;
//import com.fasterxml.jackson.databind.ser.Serializers;
//import org.apache.commons.codec.digest.DigestUtils;
//import org.apache.commons.codec.digest.Md5Crypt;
//
//import java.io.UnsupportedEncodingException;
//import java.util.Base64;
//
///**
// * @ClassName JwtTest004
// * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
// * @Version V1.0
// **/
//public class JwtTest004 {
//    private static final String SIGN_KEY = "mayiktSignKey";
//
//    public static void main(String[] args) throws UnsupportedEncodingException {
//
//        JSONObject head = new JSONObject();
//        head.put("alg", "HS256");
//        JSONObject payLoad = new JSONObject();
//        payLoad.put("phone", "1592*****100");
//
//        String headJwt = Base64.getEncoder().encodeToString(head.toJSONString().getBytes());
//        String payLoadJsonStr = payLoad.toJSONString();
//        String payLoadJwt = Base64.getEncoder().encodeToString(payLoadJsonStr.getBytes());
//        String sign = DigestUtils.md5Hex((payLoadJsonStr + SIGN_KEY).getBytes());
//        String jwt = headJwt + "." + payLoadJwt + "." + sign;
//        System.out.println(jwt);
//
//        // 解密
//        String payLoadEncode = jwt.split("\\.")[1];
//        String payLoadDecoder = new String(Base64.getDecoder().decode(payLoadEncode), "UTF-8");
//        System.out.println(DigestUtils.md5Hex((payLoadDecoder + SIGN_KEY).getBytes()).equals(jwt.split("\\.")[2]));
//
//    }
//}
